<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>修改密码</title>
<link href="../webjars/bootstrap/3.3.7-1/css/bootstrap.css" rel="stylesheet" type="text/css">
<link href="../webjars/bootstrap/3.3.7-1/css/bootstrap-theme.css" rel="stylesheet" type="text/css">
<script src="../static/jquery-easyui-1.5.5.3/jquery.min.js"></script>
<script src="../webjars/bootstrap/3.3.7-1/js/bootstrap.js"></script> 
<style type="text/css">
	*{
		margin: 0px;
		padding: 0px;
	}
	
</style>
</head>
<body>
<div>
	<form action="" method="post">
		<span class="input-group-addon">输入原密码：</span>
		<input type="password" class="form-control" id="pad" onchange="fun(this.value);" placeholder="在此输入原密码"><br>
		<div><label id="pad-error" class="error col-lg-offset-3" for="pad"></label></div><br>
		<span class="input-group-addon">输入新密码：</span>
		<input type="password" class="form-control" id="pad1" placeholder="在此输入新密码"><br>
		<div><label id="pad1-error" class="error col-lg-offset-3" for="pad1"></label></div><br>
		<span class="input-group-addon">确认密码：</span>
		<input type="password" class="form-control" id="pad2" placeholder="请最后确认密码"><br>
		<div><label id="pad2-error" class="error col-lg-offset-3" for="pad2"></label></div><br>
		<button type="button" id = "btn_1" class="btn btn-primary" style="width:100%;">确定</button>
	</form>
</div>
<script type="text/javascript">
		function fun(str){
			$.post('pwd', {password: str}, function(data){
				if(! data){
					$("#pad-error").html("原密码输入错误");
				}else {
					$("#pad-error").html("");
				}
			});
		}
		
		$("#btn_1").click(function(){
			var pad1 = $("#pad1").val();
			var pad2 = $("#pad2").val();
			var str = $("#pad").val();
			var f = false;
			if(str == "" || str == null){
				f = true;
				$("#pad-error").html("请输入原密码");
			}else if(pad1 == "" || pad1 == null){
				f = true;
				$("#pad1-error").html("请输入密码");
			}else if(pad2 == "" || pad2 == null){
				f = true;
				$("#pad1-error").html("");
				$("#pad2-error").html("请确认密码");
			}else if(pad1 != pad2){
				f = true;
				$("#pad1-error").html("");
				$("#pad2-error").html("两次密码不一致");
			}
			$.post('pwd', {password: str}, function(data){
				f = data;
			});
			if(!f){
				alert("修改成功,请重新登陆！");
				window.parent.location="xg?pad="+pad1;
			}
		});
	</script>
</body>
</html>